#include "mima.h"
#include "dcuinformation.h"

Mima::mima(QWidget *parent) :
    QWidget(parent)
{
    setFixedSize(655,363);
    setWindowFlags(Qt::FramelessWindowHint);
    setAutoFillBackground(true);
    background = palette();
    background.setBrush(QPalette::Window,QBrush(QPixmap(":/images/SelectLinesbg.png")));
    setPalette(background);

    LoopNumberDecrease = new QPushButton(this);
    LoopNumberDecrease->setGeometry(QRect(178, 277, 45, 45));
    LoopNumberDecrease->setStyleSheet("QPushButton{border-image: url(:/images/DecreasePulled.png)}"
                                      "QPushButton:pressed{border-image: url(:/images/DecreasePushed.png);}");
    connect(LoopNumberDecrease, SIGNAL(clicked()), this, SLOT(DecreaseLoopNumber()));

    LoopNumberIncrease = new QPushButton(this);
    LoopNumberIncrease->setGeometry(QRect(266, 277, 45, 45));
    LoopNumberIncrease->setStyleSheet("QPushButton{border-image: url(:/images/IncreasePulled.png)}"
                                      "QPushButton:pressed{border-image: url(:/images/IncreasePushed.png);}");
    connect(LoopNumberIncrease, SIGNAL(clicked()), this, SLOT(IncreaseLoopNumber()));

    LoopNumber = new QLabel(this);
    LoopNumber->setText(QString("%1").arg(StationInfo.SpecialGBLoopNumber));
    LoopNumber->setAlignment(Qt::AlignCenter);
    LoopNumber->setFont(QFont(ZITI, 20, QFont::Bold));
    LoopNumber->setGeometry(QRect(221, 277, 45, 45));
    LoopNumber->setStyleSheet("color:white;text-align:center;");

    Loop = new QLabel(this);
    Loop->setText("循环次数");
    Loop->setAlignment(Qt::AlignCenter);
    Loop->setFont(QFont(ZITI, 22, QFont::Bold));
    Loop->setGeometry(QRect(70, 277, 100, 45));
    Loop->setStyleSheet("color:white;text-align:center;");

    OK = new QPushButton(this);
    OK->setText(tr("确认"));
    OK->setFont(QFont(ZITI, 20, QFont::Normal));
    OK->setGeometry(QRect(393, 277, 111, 46));
    OK->setStyleSheet("QPushButton{border-image: url(:/images/ButtonPulled.png);color:rgb(19,60,76)}"
                      "QPushButton:pressed{border-image: url(:/images/ButtonPushed.png);}");

    Cancel = new QPushButton(this);
    Cancel->setText(tr("返回"));
    Cancel->setFont(QFont(ZITI, 20, QFont::Normal));
    Cancel->setGeometry(QRect(515, 277, 111, 46));
    Cancel->setStyleSheet("QPushButton{border-image: url(:/images/ButtonPulled.png);color:rgb(19,60,76)}"
                          "QPushButton:pressed{border-image: url(:/images/ButtonPushed.png);}");
}

void SpecialGB::IncreaseLoopNumber()
{
    if(StationInfo.SpecialGBLoopNumber == 255)
    {
        StationInfo.SpecialGBLoopNumber = 0;
        LoopNumber->setText("无限");
    }
    else
    {
        StationInfo.SpecialGBLoopNumber++;
        LoopNumber->setText(QString("%1").arg(StationInfo.SpecialGBLoopNumber));
    }
}

void SpecialGB::DecreaseLoopNumber()
{
    if(StationInfo.SpecialGBLoopNumber == 1)
    {
        StationInfo.SpecialGBLoopNumber = 0;
        LoopNumber->setText("无限");
    }
    else
    {
        StationInfo.SpecialGBLoopNumber--;
        LoopNumber->setText(QString("%1").arg(StationInfo.SpecialGBLoopNumber));
    }
}
